#pragma once

class CConsoleEnv
{
public:
    CConsoleEnv()
    {
        AllocConsole();
        FILE* lpFile;
        freopen_s(&lpFile, "conin$", "r+t", stdin);
        freopen_s(&lpFile, "conout$", "w+t", stdout);
        freopen_s(&lpFile, "conout$", "w+t", stderr);
    }

    ~CConsoleEnv()
    {
        fclose(stderr);
        fclose(stdout);
        fclose(stdin);
        FreeConsole();
    }

public:
    static void Init()
    {
        static CConsoleEnv ConsoleEnv;
    }
};
